package main

import (
	"log"
	"net/http"
	"ocr/config"
	_ "ocr/web"
)

func main() {
	//监听端口
	addr := config.OcrConfig.GetString("HttpConf.IP") + ":" + config.OcrConfig.GetString("HttpConf.Port")
	err := http.ListenAndServe(addr, nil)
	if err != nil {
		log.Println(err.Error())
	}

}

//   http://127.0.0.1/ocr/general/basic
//   http://127.0.0.1/ocr/health/code
//   http://127.0.0.1/ocr/travel/card

/*
func main() {
	request := ocr.NewGeneralBasicOCRRequest()

	request.ImageBase64 = common.StringPtr("1234567")
	request.ImageUrl = common.StringPtr("https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/general/GeneralBasicOCR/GeneralBasicOCR1.jpg")
	request.Scene = common.StringPtr("123456")
	request.LanguageType = common.StringPtr("zh")
	request.IsPdf = common.BoolPtr(false)
	request.PdfPageNumber = common.Uint64Ptr(0)
	request.IsWords = common.BoolPtr(false)
	response, err := ocr.GeneralBasicOCR(request)
	if err != nil {
		log.Println(err.Error())
		return
	}
	fmt.Printf("%s", response.ToJsonString())
}
*/
/*
func main() {
	// 实例化一个认证对象，入参需要传入腾讯云账户secretId，secretKey,此处还需注意密钥对的保密
	// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
	credential := common.NewCredential(
		config.OcrSecret.GetString("OcrSecret.SecretId"),
		config.OcrSecret.GetString("OcrSecret.SecretKey"),
	)
	// 实例化一个client选项，可选的，没有特殊需求可以跳过
	cpf := profile.NewClientProfile()
	cpf.HttpProfile.Endpoint = config.OcrConfig.GetString("OcrConf.Endpoint")
	// 实例化要请求产品的client对象,clientProfile是可选的
	client, _ := ocr.NewClient(credential, config.OcrConfig.GetString("OcrConf.Region"), cpf)

	// 实例化一个请求对象,每个接口都会对应一个request对象
	request := ocr.NewGeneralBasicOCRRequest()

	request.ImageBase64 = common.StringPtr("1234567")
	request.ImageUrl = common.StringPtr("https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/general/GeneralBasicOCR/GeneralBasicOCR1.jpg")
	request.Scene = common.StringPtr("123456")
	request.LanguageType = common.StringPtr("zh")
	request.IsPdf = common.BoolPtr(false)
	request.PdfPageNumber = common.Uint64Ptr(0)
	request.IsWords = common.BoolPtr(false)

	// 返回的resp是一个GeneralBasicOCRResponse的实例，与请求对象对应
	response, err := client.GeneralBasicOCR(request)
	if _, ok := err.(*errors.TencentCloudSDKError); ok {
		fmt.Printf("An API error has returned: %s", err)
		return
	}
	if err != nil {
		panic(err)
	}
	// 输出json格式的字符串回包
	fmt.Printf("%s", response.ToJsonString())
}
*/
